<html>

<head>
    <meta charset="utf-8">
    <!-- 开发环境版本，包含了有帮助的命令行警告 -->
    <!-- <script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script> -->
    <script src="vue.js"></script>
    <style>
        .red {
            color: red;
        }

        .green {
            color: green;
        }

        .thin {
            font-weight: 200;
        }

        .italic {
            font-style: italic;
        }

        .active {
            letter-spacing: 0.5em;
        }
    </style>

</head>

<body>
    <div id="app">
        <div>
            <label>ID:
                <input type="text" v-model="id">
            </label>
            <label>Name:
                <input type="text" v-model="name">
            </label>
            <input type="button" value="add" @click="add">
        </div>
        <p v-for="(item,i) in list4" :key="item.id">
            <input type="checkbox">
            {{item.id}} --- {{item.name}}
        </p>

        <p>{{list[0]}}</p>
        <p>{{list[1]}}</p>

        <p v-for="(item,i) in list">{{i}} --- {{item}}</p>
        <p v-for="user in list2">{{user.id}} --- {{user.name}}</p>
        <p v-for="(val,key,index) in list3">{{key}} --- {{val}} --- {{index}}</p>

        <p v-for="count in 10">第{{count}}次</p>
    </div>
    <script>
        var vm = new Vue({
            el: '#app',
            data: {
                list: [1, 2, 3, 4, 5, 6],
                list2: [
                    { id: 1, name: 'zs1' },
                    { id: 2, name: 'zs2' },
                    { id: 3, name: 'zs3' },
                    { id: 4, name: 'zs4' },
                ],
                list3: { id: 1, name: 'zs1', gender: '男' },

                id: '',
                name: '',
                list4: [
                    { id: 1, name: 'zs1' },
                    { id: 2, name: 'zs2' },
                    { id: 3, name: 'zs3' },
                    { id: 4, name: 'zs4' },
                ],

            },
            methods: {


                add() {
                    console.log('这里触发了 btn的点击事件')
                    // this.list4.push({id:this.id,name:this.name})   
                    this.list4.unshift({ id: this.id, name: this.name })
                }

            },
        })
    </script>
</body>


</html>